<?php
class InformationController extends AppController {

	var $name = 'Information';
	var $helpers = array('Html', 'Form');
	
	function beforeFilter() {
		parent::beforeFilter(); 		
		$this->Auth->allow('*');
	}

	function index() {
		$this->Information->recursive = 0;
		$this->set('information', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->flash(__('Invalid Information', true), array('action' => 'index'));
		}
		$this->set('information', $this->Information->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Information->create();
			if ($this->Information->save($this->data)) {
				$this->flash(__('Information saved.', true), array('action' => 'index'));
			} else {
			}
		}
		$users = $this->Information->User->find('list');
		$this->set(compact('users'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->flash(__('Invalid Information', true), array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Information->save($this->data)) {
				$this->flash(__('The Information has been saved.', true), array('action' => 'index'));
			} else {
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Information->read(null, $id);
		}
		$users = $this->Information->User->find('list');
		$this->set(compact('users'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->flash(__('Invalid Information', true), array('action' => 'index'));
		}
		if ($this->Information->del($id)) {
			$this->flash(__('Information deleted', true), array('action' => 'index'));
		}
		$this->flash(__('The Information could not be deleted. Please, try again.', true), array('action' => 'index'));
	}


	function admin_index() {
		$this->Information->recursive = 0;
		$this->set('information', $this->paginate());
	}

	function admin_view($id = null) {
		if (!$id) {
			$this->flash(__('Invalid Information', true), array('action' => 'index'));
		}
		$this->set('information', $this->Information->read(null, $id));
	}

	function admin_add() {
		if (!empty($this->data)) {
			$this->Information->create();
			if ($this->Information->save($this->data)) {
				$this->flash(__('Information saved.', true), array('action' => 'index'));
			} else {
			}
		}
		$users = $this->Information->User->find('list');
		$this->set(compact('users'));
	}

	function admin_edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->flash(__('Invalid Information', true), array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Information->save($this->data)) {
				$this->flash(__('The Information has been saved.', true), array('action' => 'index'));
			} else {
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Information->read(null, $id);
		}
		$users = $this->Information->User->find('list');
		$this->set(compact('users'));
	}

	function admin_delete($id = null) {
		if (!$id) {
			$this->flash(__('Invalid Information', true), array('action' => 'index'));
		}
		if ($this->Information->del($id)) {
			$this->flash(__('Information deleted', true), array('action' => 'index'));
		}
		$this->flash(__('The Information could not be deleted. Please, try again.', true), array('action' => 'index'));
	}

}
?>